package com.smart.campus.controller;

import com.smart.campus.dto.ShCheck;
import com.smart.campus.pojo.PagedResponse;
import com.smart.campus.pojo.ResponseResult;
import com.smart.campus.service.ShCheckFeign;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @BelongsProject: smart-campus
 * @BelongsPackage: com.smart.campus.controller
 * @Author: 戴冰洁
 * @CreateTime: 2024-10-08  14:03
 * @Description: TODO
 * @Version: 1.0
 */
@Api(tags = "历史考勤模块")
@Slf4j
@RestController
@RequestMapping(value = "shcheck")
public class ShCheckController {
    @Autowired
    private ShCheckFeign shCheckFeign;
    @ApiOperation(value = "历史考勤查询", httpMethod = "GET", notes = "历史考勤查询")
    @RequestMapping(value = "findshcheck")
    public ResponseResult<List<ShCheck>> findshcheck(){
        return new ResponseResult<>(200,"查询成功",shCheckFeign.findshcheck());
    }
    @ApiOperation(value = "历史考勤新增",httpMethod = "POST",notes = "历史考勤新增")
    @RequestMapping(value = "addshcheck")
    public ResponseResult addshcheck(@RequestBody ShCheck shCheck){
        try {
            shCheckFeign.addshcheck(shCheck);
            return new ResponseResult(200,"成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult(444,"失败");
        }
    }
    @ApiOperation(value = "删除信息", httpMethod = "GET", notes = "删除信息")
    @RequestMapping(value = "deleteshcheck")
    public ResponseResult deleteshcheck(@RequestParam(value = "id") Integer id){
        try {
            shCheckFeign.deleteshcheck(id);
            return new ResponseResult(200,"删除成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult(444,"删除失败");
        }
    }
    @ApiOperation(value = "缺勤回显",httpMethod = "POST",notes = "缺勤回显")
    @RequestMapping(value = "shcheckList")
    public ResponseResult<ShCheck> shcheckList(Integer id){
        return new ResponseResult<>(200,"回显成功",shCheckFeign.shcheckList(id));
    }
    @ApiOperation(value = "修改信息", httpMethod = "POST", notes = "修改信息")
    @RequestMapping(value = "updateshcheck")
    public ResponseResult updateshcheck(@RequestBody ShCheck shCheck){
        try {
            shCheckFeign.updateshcheck(shCheck);
            return new ResponseResult(200,"修改成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult(444,"修改失败");
        }
    }
    @ApiOperation(value = "分页查询",httpMethod = "POST", notes = "分页查询")
    @RequestMapping(value = "pageShChenck")
    public ResponseResult<PagedResponse<ShCheck>> pageShChenck(@RequestBody ShCheck shCheck,@RequestParam(value = "pageNum")Integer pageNum,@RequestParam("pageSize")Integer pageSize){
        return new ResponseResult<>(200,"成功",shCheckFeign.pageShChenck(shCheck,pageNum,pageSize));
    }
}
